import { User, UserProfile } from '@/types/data'
import { ProfileAction } from '@/types/store'

type ProfileProps = {
  user: User
  userProfile: UserProfile
}
const initialState: ProfileProps = {
  user: {},
  userProfile: {}
} as ProfileProps

const profile = (state = initialState, action: ProfileAction) => {
  console.log('profile', action)
  if (action.type === 'profile/getUser') {
    return { ...state, user: action.payload }
  } else if (action.type === 'profile/getUserProfile') {
    return { ...state, userProfile: action.payload }
  }
  return state
}

export default profile
